HYBRIDJOIN Algorithm

Once the memory is distributed among the join components HYBRIDJOIN starts its execution according to the procedure mentioned below.
Normally the join algorithm continues its execution for an infinite amount of time (line 1). In each iteration, the algorithm takes
the value of a join attribute from the queue (line 2) and loads a disk page into the disk buffer, using that join attribute value as
a index (line 3). After loading the disk page into memory the algorithm reads one by one all tuples from that disk page and probes
them in the hash table. In the case of a match, the algorithm generates that tuple as an output and deletes it from the hash table
along with the corresponding node from the queue. The algorithm also increments variable w, which contains the next input size
for the stream (line 4-9). When the entire disk page is probed the algorithm reads the w tuples from the stream buffer if available,
loads them into the hash table, and enques their attribute values in the queue. Once the stream input is read the algorithm resets
the value of w to zero (line 11-13).


********************************************HYBRIDJOIN algorithm****************************************************

Input: A disk-based relation R with an index on join attribute and a Stream of updates S
Output: S join R
Parameters: w tuples of S and b pages of R
Method:
1: WHILE (true) DO
2: 	READ join attribute value from Q.
3: 	READ a page p of R into disk buffer using join attribute value as an index.
4: 	FOR each tuple r in page p DO
5: 		IF r exists in H THEN
6: 			OUTPUT r exists in H
7: 			DELETE the matched tuple from H and the corresponding node from Q.
8: 			w=w + 1
9: 		END IF
10: 	END FOR
11: 	IF (stream available) THEN
12: 		READ w tuples form stream buffer and load them into H while enqueing their
		join attribute values into Q.
13: 		RESET w to zero
14: 	END IF
15: END WHILE

*********************************************************************************************************************